<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<title><?php echo ($name); ?></title>
<script src="__APP__/statics/jquery-1.9.1.min.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="__APP__/statics/css/jNotify.jquery.css" />
<script type="text/javascript" src="__APP__/statics/jNotify.jquery.js"></script>
<style>
 body{font-family:"微软雅黑";font-size:12px;color:#666666;background-color:#F9F9F6}
 *{margin: 0;} 
 a{text-decoration:none}
 img{border:0px}
.cat{background-color:#F9F9F6;margin-left:10px;z-index:0;}
.cat_list:hover{background-color:#fff;}
.title{background:url("__APP__/statics/tbg.gif");font-weight:bold}

#save{text-align:center;border:0;width:100%;height:40px;background-color:#fff;position:fixed;left:0px;bottom:0px;z-index:999;border:1px solid #DFDFDF;background-color:#DFDFDF;padding:5px;height:20px}
</style>

<div class="cat">
<a href="__URL__/add"><img src="__APP__/statics/add_cat.gif" /></a>
<table bordercolor="#DDDFFF" border="1" width="100%" style="border-collapse: collapse" cellpadding="3">
	<tr height="17" align="center">
		<td class="title" width="40">排序</td>
		<td class="title" width="300">分类名称</td>
		<td class="title" width="100">类型</td>
		<td class="title" width="40">图标</td>
		<td class="title" width="80">添加子类</td>
		<td class="title" width="40">修改</td>
		<td class="title" width="40">删除</td>
		<td class="title" width="80">查看商品</td>
		<td class="title" width="40">浏览</td>
		<td class="title" width="40">显示</td>
		<td class="title" width="40">推荐</td>
		<td class="title">　</td>
	</tr>
<?php if(is_array($cat)): $i = 0; $__LIST__ = $cat;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$cat): $mod = ($i % 2 );++$i;?><tr height="20" bgcolor="#F1F5FA" class="cat_list">
		<td width="40"><input type="text" name="n_id[]" style="display:none" value="<?php echo ($cat["cat_id"]); ?>"><input name="sorting[]" size="10" type="text" value="<?php echo ($cat["sorting"]); ?>"></td>
<?php if($cat["pid"] == 0): ?><td width="300" style="font-weight:bold">[<?php echo ($cat["fullname"]); ?>]</td>
<?php else: ?>
        <td width="300"><?php echo ($cat["fullname"]); ?></td><?php endif; ?>
		<td width="100">[<?php echo ($cat["model_n"]); ?>]</td>
		<td><?php if($cat["icon"] != ''): ?><img src="__APP__/statics/icons/cate/<?php echo ($cat["icon"]); ?>" width='25px' height="25px"><?php endif; ?></td>
		<td width="80" align="center"><a href="__URL__/add/?pid=<?php echo ($cat["cat_id"]); ?>&model=<?php echo ($cat["model"]); ?>"><img src="__APP__/statics/add44.gif"></a></td>
		<td width="40" align="center"><a href="__URL__/edit/?cat=<?php echo ($cat["cat_id"]); ?>"><img src="__APP__/statics/icons/member3.gif"></a></td>
		<td width="40" align="center"><a href="javascript:;" onclick="delCat(<?php echo ($cat["cat_id"]); ?>)"><img alt="删除" src="__APP__/statics/icons/icon_delete.gif"></a></td>
		<td width="80" align="center"><a href="__GROUP__/Goods/goods_list/?cat=<?php echo ($cat["cat_id"]); ?>"><img src="__APP__/statics/icons/cart.gif"></a></td>
		<td width="40" align="center"><a href="__APP__/List/?cid=<?php echo ($cat["cat_id"]); ?>" target="_blank"><img src="__APP__/statics/reg-t1.gif"></a></td>
		<td><?php if($cat["is_active"] == 0): ?>显示<?php else: ?><font color='red'>不显示</font><?php endif; ?></td>
		<td><?php if($cat["is_hot"] == 1): ?><font color='green'>推荐</font><?php else: ?>不推荐<?php endif; ?></td>
		<td></td>
	</tr><?php endforeach; endif; else: echo "" ;endif; ?>
</table>
</div>

<div id="save"><input id="sort" type="button" value="保存排序"></div>

<script>
$(function(){
    $("#sort").click(function(){
              var cat=[];
			  $("[name='n_id[]']").each(function(){
                     cat.push($(this).val()); 
               }); 
			   var sort=[];
			  $("[name='sorting[]']").each(function(){
                     sort.push($(this).val()); 
               }); 
			   $.ajax({
			         type:"POST",
					 url:"__URL__/sorting",
					 dataType:"html",
					 data:{'cat':cat,'sort':sort},
					 success:function(data){
						location.reload();
					 }
			   })
	})
})

function delCat(t){
    var id=t;
	//jError("<strong>删除失败!请重试</strong>",{VerticalPosition : 'center',HorizontalPosition : 'center'});
	if(confirm('你确认删除此分类吗？如果有子分类或者该分类下有商品将无法删除！')) {
		$.ajax({
			 type:"POST",
			 url:"__URL__/del_cat",
			 dataType:"json",
			 data:{'id':id},
			 success:function(data){
				if(data=='0'){
					jError("<strong>删除失败!可能存在子分类或该分类下有未转移商品</strong>",{VerticalPosition : 'center',HorizontalPosition : 'center'});
				}else{
					jSuccess("<strong>删除成功！</strong>",{VerticalPosition : 'center',HorizontalPosition : 'center'});
					location.reload();
				}
			 }
		})
	}
}
</script>